<?php
namespace RTSCraft\MainBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Doctrine\ORM\Mapping\OrderBy;
use Doctrine\ORM\Mapping\JoinColumn;

/**
 * @ORM\Entity(repositoryClass="RTSCraft\MainBundle\Repository\ArticleRepository")
 * @ORM\Table(name="Article", uniqueConstraints={@UniqueConstraint(name="title_unique", columns={"title"})})
 */
class Article
{
  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $id;

  /**
   * @ORM\Column(type="string", length="256")
   */
  protected $title;

  /**
   * @ORM\OneToOne(targetEntity="Element")
   * @ORM\JoinColumn(name="element_id", referencedColumnName="id")
   */
  protected $element;

  /**
   * @ORM\OneToMany(targetEntity="Version", mappedBy="article_id")
   */
  protected $versions;

    public function __construct()
    {
        $this->versions = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param text $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * Get title
     *
     * @return text 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Add versions
     *
     * @param RTSCraft\MainBundle\Entity\Version $versions
     */
    public function addVersion(\RTSCraft\MainBundle\Entity\Version $versions)
    {
        $this->versions[] = $versions;
    }

    /**
     * Get versions
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getVersions()
    {
        return $this->versions;
    }

    /**
     * Set element
     *
     * @param RTSCraft\MainBundle\Entity\Element $element
     */
    public function setElement(\RTSCraft\MainBundle\Entity\Element $element)
    {
        $this->element = $element;
    }

    /**
     * Get element
     *
     * @return RTSCraft\MainBundle\Entity\Element 
     */
    public function getElement()
    {
        return $this->element;
    }
}